<!--
 * @Description: 
 * @version: 
 * @Author: 尹鹏孝
 * @Date: 2022-01-10 11:24:07
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2022-01-10 14:54:52
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>bind-reduce</title>
</head>

<body>
    <script>
        const obj = {
            base: 42,
            add(...nums) {
                return nums.reduce((totle, current) => current + totle, this.base || 0);
            },
        };

        const f1 = obj.add.bind({ base: 3 }, [0]);
        console.log(f1(1));
        [[0], 1].reduce((totle, current) => {
            console.log(totle);
            console.log(current);
            console.log(current + totle);
            return current + totle
        }, 3)
       /*  const f2 = obj.add.bind({}, 1);
                 const f3 = obj.add.bind({ base: 2 }, [1]);
                 console.log(f1(1), f2(1), f3(1));
                 console.log(f1(2), f2(2), f3(2));
                 console.log(f1(3), f2(3), f3(3));
                 console.log(f1(4), f2(4), f3(4)); */
    </script>
</body>

</html>